<?php
namespace Common\Controller;

class UserController extends FrontController{

	public function _initialize(){
		parent::_initialize();
		$uid = intval($_REQUEST['uid']) ? intval($_REQUEST['uid']) : is_login();
		if (!$uid) {
			$this->error('需要登录',U('User/Public/login'));
		}
		$this->setLeftNav();
		$this->assign('uid', $uid);
		$this->assign('username', session('user_auth.username'));
		$this->mid = is_login();
	}


	protected function setLeftNav(){
		$left_nav = array(
			'config'   => array(
				array('name'=>'资料修改','url'=>U('User/Config/index'),'icon'=>''),
				array('name'=>'更换头像','url'=>U('User/Config/avatar'),'icon'=>''),
				array('name'=>'密码修改','url'=>U('User/Config/changepwd'),'icon'=>''),
			),
			'content'  => array(
				array('name'=>'文档管理','url'=>U('User/Article/index'),'icon'=>'')
			)
		);

		Hook('extend_user_nav');
		$nav = C('extend_user_nav');
		foreach ($nav as $key => $value) {
			foreach ($value as $k => $v) {
				$left_nav[$k][] = $v;
			}
		}
		$this->assign('user_left_nav',$left_nav);
	}
}